import {defineStore} from 'pinia';
import {getTheme, setTheme, Theme} from "@/utils/theme.ts";


export const useThemeStore = defineStore('theme', {
    state: () => {
        return {
            isDark: getTheme() === Theme.Dark
        }
    },
    getters: {
        getTheme(): boolean {
            return this.isDark;
        }
    },
    actions: {
        changeTheme() {
            this.isDark = !this.isDark;
            setTheme(this.isDark ? Theme.Dark : Theme.Light);
        }
        // 异步
        // async getTheme(){
        //     const res = await axios.get('https://test.com/api/getTheme');
        //     if(res.data.code == 200){
        //         this.list = res.data.result || [];
        //     }
        // },
    }
})
